package com.demo2do.fms.entity.supplier.common;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;

/**
 * 
 * 服务供方过往业务信息(汽运、仓库共用)
 * 
 * @author Wy
 *
 */
@Entity
@Table(name = "FMS_SUPPLIER_BUSINESS_HISTORY")
@DynamicInsert
@DynamicUpdate
public class SupplierBusinessHistory {
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 所属supplier */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @PersistentFormat
    private Supplier supplier;
    
    /** 合同起始日期 - 共用 */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startDate;
    
    /** 合同终止日期 - 共用 */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;
    
    /** 合同甲方 - 共用 */
    private String consignor;
    
    /** 合同乙方 - 共用 */
    private String executor;
    
    /** 承运品牌 - 共用 */
    private String brand;
    
    /** 客户合同上传*/
    private String contractFile;
    
    
    
    /** 出发地 - 汽运用 */
    private String fromLoadPlace;
    
    /** 目的地 - 汽运用 */
    private String toLoadPlace;
    
    /** 投入运力板 - 汽运用 */
    private BigDecimal vehicleNum;
    
    /** 月均运量 - 汽运用 */
    private BigDecimal averageCapacity;
    
    /** 汽运业务类型 - 汽运用 */
    @Enumerated(EnumType.ORDINAL)
    private TransType transType;
    
    
    
    /** 服务仓库所在地 - 仓储用 */
    private String serviceLocation;
    
    /** 投入人员 - 仓储用 */
    private BigDecimal staffNum;
    
    /** 月均业务量 - 仓储用  */
    private BigDecimal averageTraffic;
    
    /** 仓储业务类型 - 仓储用 */
    @Enumerated(EnumType.ORDINAL)
    private WareType wareType;
    
    
    
    /** 创建者*/
    private Long creator;
    
    /** 创建时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    
    /** 修改者*/
    private Long lastOperator;
    
    /** 上次修改时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModifyTime;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public SupplierBusinessHistory(){
    }
    
    /**
     * 
     * @param supplier
     */
    public SupplierBusinessHistory(Supplier supplier){
        this.supplier = supplier;
    }
    
    /**
     * @param operator
     * @return
     */
    public SupplierBusinessHistory initialize(Long operator) {
        this.creator = operator;
        this.createTime = new Date();
        this.lastOperator = operator;
        this.lastModifyTime = new Date();
        this.disabled = false;
        return this;
    }
    
    /**
     * edit
     * 
     * @param loginId
     * @return
     */
    public SupplierBusinessHistory edit(Long loginId) {
        this.lastOperator = loginId;
        this.lastModifyTime = new Date();
        return this;
    }
    
    /**
     * @param operator
     * @param now
     * @return
     */
    public SupplierBusinessHistory operate(Long operator, Date now) {
        this.lastOperator = operator;
        this.lastModifyTime = now;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public SupplierBusinessHistory delete() {
        this.disabled = true;
        this.lastModifyTime = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the supplier
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * @return the startDate
     */
    public Date getStartDate() {
        return startDate;
    }

    /**
     * @return the endDate
     */
    public Date getEndDate() {
        return endDate;
    }

    /**
     * @return the consignor
     */
    public String getConsignor() {
        return consignor;
    }

    /**
     * @return the executor
     */
    public String getExecutor() {
        return executor;
    }

    /**
     * @return the brand
     */
    public String getBrand() {
        return brand;
    }

    /**
     * @return the fromLoadPlace
     */
    public String getFromLoadPlace() {
        return fromLoadPlace;
    }

    /**
     * @return the toLoadPlace
     */
    public String getToLoadPlace() {
        return toLoadPlace;
    }

    /**
     * @return the vehicleNum
     */
    public BigDecimal getVehicleNum() {
        return vehicleNum;
    }

    /**
     * @return the averageCapacity
     */
    public BigDecimal getAverageCapacity() {
        return averageCapacity;
    }

    /**
     * @return the transType
     */
    public TransType getTransType() {
        return transType;
    }

    /**
     * @return the serviceLocation
     */
    public String getServiceLocation() {
        return serviceLocation;
    }

    /**
     * @return the staffNum
     */
    public BigDecimal getStaffNum() {
        return staffNum;
    }

    /**
     * @return the averageTraffic
     */
    public BigDecimal getAverageTraffic() {
        return averageTraffic;
    }

    /**
     * @return the wareType
     */
    public WareType getWareType() {
        return wareType;
    }

    /**
     * @return the contractFile
     */
    public String getContractFile() {
        return contractFile;
    }

    /**
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param supplier the supplier to set
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * @param startDate the startDate to set
     */
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    /**
     * @param endDate the endDate to set
     */
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    /**
     * @param consignor the consignor to set
     */
    public void setConsignor(String consignor) {
        this.consignor = consignor;
    }

    /**
     * @param executor the executor to set
     */
    public void setExecutor(String executor) {
        this.executor = executor;
    }

    /**
     * @param brand the brand to set
     */
    public void setBrand(String brand) {
        this.brand = brand;
    }

    /**
     * @param fromLoadPlace the fromLoadPlace to set
     */
    public void setFromLoadPlace(String fromLoadPlace) {
        this.fromLoadPlace = fromLoadPlace;
    }

    /**
     * @param toLoadPlace the toLoadPlace to set
     */
    public void setToLoadPlace(String toLoadPlace) {
        this.toLoadPlace = toLoadPlace;
    }

    /**
     * @param vehicleNum the vehicleNum to set
     */
    public void setVehicleNum(BigDecimal vehicleNum) {
        this.vehicleNum = vehicleNum;
    }

    /**
     * @param averageCapacity the averageCapacity to set
     */
    public void setAverageCapacity(BigDecimal averageCapacity) {
        this.averageCapacity = averageCapacity;
    }

    /**
     * @param transType the transType to set
     */
    public void setTransType(TransType transType) {
        this.transType = transType;
    }

    /**
     * @param serviceLocation the serviceLocation to set
     */
    public void setServiceLocation(String serviceLocation) {
        this.serviceLocation = serviceLocation;
    }

    /**
     * @param staffNum the staffNum to set
     */
    public void setStaffNum(BigDecimal staffNum) {
        this.staffNum = staffNum;
    }

    /**
     * @param averageTraffic the averageTraffic to set
     */
    public void setAverageTraffic(BigDecimal averageTraffic) {
        this.averageTraffic = averageTraffic;
    }

    /**
     * @param wareType the wareType to set
     */
    public void setWareType(WareType wareType) {
        this.wareType = wareType;
    }

    /**
     * @param contractFile the contractFile to set
     */
    public void setContractFile(String contractFile) {
        this.contractFile = contractFile;
    }

    /**
     * @param creator the creator to set
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}